package br.com.moxeon.model.cash;

import java.util.Date;
import java.util.List;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Enumerated;
import javax.persistence.FetchType;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.persistence.Transient;

import org.hibernate.annotations.Cascade;
import org.hibernate.annotations.CascadeType;

import br.com.moxeon.model.Accounts;
import br.com.moxeon.model.MoxeonControlledPersistentEntity;
import br.com.moxeon.model.enums.TypeThrowOperation;
import br.com.vexillum.model.annotations.ValidatorClass;

@SuppressWarnings("serial")
@Entity
@Table(name = "throw_operation")
@ValidatorClass(validatorClass = "br.com.moxeon.control.validator.ThrowOperationValidator")
public class ThrowOperation extends MoxeonControlledPersistentEntity {


	@Enumerated
	@Column(name = "operation_type", nullable = true)
	private TypeThrowOperation tipoOperacao;

	@OneToMany(targetEntity = Accounts.class, fetch = FetchType.LAZY, mappedBy = "operation")
	@Cascade(value={CascadeType.SAVE_UPDATE, CascadeType.PERSIST, CascadeType.MERGE})
	private List<Accounts> payableAccounts;

	@OneToMany(targetEntity = Accounts.class, fetch = FetchType.LAZY, mappedBy = "operation")
	@Cascade(value={CascadeType.SAVE_UPDATE, CascadeType.PERSIST, CascadeType.MERGE})
	private List<Accounts> receivableAccounts;

	@OneToMany(targetEntity = Throw.class, fetch = FetchType.LAZY, mappedBy = "operation")
	@Cascade(value={CascadeType.SAVE_UPDATE, CascadeType.PERSIST, CascadeType.MERGE})
	private List<Throw> listThorws;
	
	@Transient
	private Throw thorw;

	@Column(name = "operation_date", nullable = false)
	private Date oparationDate;
	
	@Column(name = "reverse_operation_date", nullable = true)	
	private Date reverseOperationDate;
	
	private String observation;

	public TypeThrowOperation getTipoOperacao() {
		return tipoOperacao;
	}

	public List<Accounts> getPayableAccounts() {
		return payableAccounts;
	}

	public List<Accounts> getReceivableAccounts() {
		return receivableAccounts;
	}

	public List<Throw> getListThorws() {
		return listThorws;
	}

	public Date getOparationDate() {
		return oparationDate;
	}

	public void setTipoOperacao(TypeThrowOperation tipoOperacao) {
		this.tipoOperacao = tipoOperacao;
	}

	public void setPayableAccounts(List<Accounts> payableAccounts) {
		this.payableAccounts = payableAccounts;
	}

	public void setReceivableAccounts(List<Accounts> receivableAccounts) {
		this.receivableAccounts = receivableAccounts;
	}

	public void setListThorws(List<Throw> listThorws) {
		this.listThorws = listThorws;
	}

	public void setOparationDate(Date oparationDate) {
		this.oparationDate = oparationDate;
	}

	public Throw getThorw() {
		return thorw;
	}

	public void setThorw(Throw thorw) {
		this.thorw = thorw;
	}

	public Date getReverseOperationDate() {
		return reverseOperationDate;
	}

	public void setReverseOperationDate(Date reverseOperationDate) {
		this.reverseOperationDate = reverseOperationDate;
	}

	public String getObservation() {
		return observation;
	}

	public void setObservation(String observation) {
		this.observation = observation;
	}

	
	
}


